home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Compilers⁄Interps / GCC-2.3.3r12 / Sources-Targets / i386rose.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-05  |  13.9 KB  |  466 lines  |  [TEXT/MPS ]

  1. /* Definitions of target machine for GNU compiler.
  2.    Intel 386 (OSF/1 with OSF/rose) version.
  3.    Copyright (C) 1991 Free Software Foundation, Inc.
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* Put leading underscores in front of names. */
  22. #define YES_UNDERSCORES
  23.  
  24. #include "halfpic.h"
  25. #include "i386gstabs.h"
  26.  
  27. #define OSF_OS
  28.  
  29. #undef  WORD_SWITCH_TAKES_ARG
  30. #define WORD_SWITCH_TAKES_ARG(STR)                    \
  31.  (!strcmp (STR, "Tdata") || !strcmp (STR, "Ttext")            \
  32.   || !strcmp (STR, "Tbss") || !strcmp (STR, "include")            \
  33.   || !strcmp (STR, "imacros") || !strcmp (STR, "aux-info")        \
  34.   || !strcmp (STR, "pic-names"))
  35.  
  36. #define MASK_HALF_PIC         0x40000000    /* Mask for half-pic code */
  37. #define MASK_HALF_PIC_DEBUG    0x20000000    /* Debug flag */
  38.  
  39. #define TARGET_HALF_PIC    (target_flags & MASK_HALF_PIC)
  40. #define TARGET_DEBUG    (target_flags & MASK_HALF_PIC_DEBUG)
  41. #define HALF_PIC_DEBUG    TARGET_DEBUG
  42.  
  43. #undef    SUBTARGET_SWITCHES
  44. #define SUBTARGET_SWITCHES \
  45.      { "half-pic",     MASK_HALF_PIC},                \
  46.      { "no-half-pic",    -MASK_HALF_PIC},                \
  47.      { "debugb",     MASK_HALF_PIC_DEBUG},
  48.  
  49. /* Prefix that appears before all global/static identifiers, except for
  50.    temporary labels.  */
  51.  
  52. #define IDENTIFIER_PREFIX "_"
  53.  
  54. /* Suffix that appears after all global/static identifiers, except for
  55.    temporary labels.  */
  56.  
  57. #define IDENTIFIER_SUFFIX ""
  58.  
  59. /* Change default predefines.  */
  60. #undef    CPP_PREDEFINES
  61. #define CPP_PREDEFINES "-DOSF -DOSF1 -Dunix -Di386"
  62.  
  63. #undef  CPP_SPEC
  64. #define CPP_SPEC "\
  65. %{.S:    -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \
  66. %{.cc:    -D__LANGUAGE_C_PLUS_PLUS} \
  67. %{.cxx:    -D__LANGUAGE_C_PLUS_PLUS} \
  68. %{.C:    -D__LANGUAGE_C_PLUS_PLUS} \
  69. %{.m:    -D__LANGUAGE_OBJECTIVE_C} \
  70. %{!.S:    -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}}"
  71.  
  72. /* Turn on -mpic-extern by default.  */
  73. #undef  CC1_SPEC
  74. #define CC1_SPEC "\
  75. %{gline:%{!g:%{!g0:%{!g1:%{!g2: -g1}}}}} \
  76. %{pic-none:   -mno-half-pic} \
  77. %{pic-lib:    -mhalf-pic} \
  78. %{pic-extern: -mhalf-pic} \
  79. %{pic-calls:  -mhalf-pic} \
  80. %{pic-names*: -mhalf-pic} \
  81. %{!pic-*:     -mhalf-pic}"
  82.  
  83. #undef    ASM_SPEC
  84. #define ASM_SPEC       ""
  85.  
  86. #undef  LINK_SPEC
  87. #define LINK_SPEC      "%{v*: -v}                           \
  88.                    %{!noshrlib: %{pic-none: -noshrlib} %{!pic-none: -warn_nopic}} \
  89.                    %{nostdlib} %{noshrlib} %{glue}"
  90.  
  91. #undef  LIB_SPEC
  92. #define LIB_SPEC "-lc"
  93.  
  94. #undef  LIBG_SPEC
  95. #define LIBG_SPEC ""
  96.  
  97. #undef  STARTFILE_SPEC
  98. #define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}"
  99.  
  100. #undef TARGET_VERSION_INTERNAL
  101. #undef TARGET_VERSION
  102.  
  103. #define I386_VERSION " 80386, OSF/rose objects"
  104.  
  105. #define TARGET_VERSION_INTERNAL(STREAM) fputs (I386_VERSION, STREAM)
  106. #define TARGET_VERSION TARGET_VERSION_INTERNAL (stderr)
  107.  
  108. #undef  MD_EXEC_PREFIX
  109. #define MD_EXEC_PREFIX        "/usr/ccs/gcc/"
  110.  
  111. #undef  MD_STARTFILE_PREFIX
  112. #define MD_STARTFILE_PREFIX    "/usr/ccs/lib/"
  113.  
  114. /* Specify size_t, ptrdiff_t, and wchar_t types.  */
  115. #undef    SIZE_TYPE
  116. #undef    PTRDIFF_TYPE
  117. #undef    WCHAR_TYPE
  118. #undef    WCHAR_TYPE_SIZE
  119.  
  120. #define SIZE_TYPE    "long unsigned int"
  121. #define PTRDIFF_TYPE    "int"
  122. #define WCHAR_TYPE    "unsigned int"
  123. #define WCHAR_TYPE_SIZE BITS_PER_WORD
  124.  
  125. /* Tell final.c we don't need a label passed to mcount.  */
  126. #define NO_PROFILE_DATA
  127.  
  128. #undef  FUNCTION_PROFILER
  129. #define FUNCTION_PROFILER(FILE, LABELNO) fprintf (FILE, "\tcall _mcount\n")
  130.  
  131. /* Some machines may desire to change what optimizations are
  132.    performed for various optimization levels.   This macro, if
  133.    defined, is executed once just after the optimization level is
  134.    determined and before the remainder of the command options have
  135.    been parsed.  Values set in this macro are used as the default
  136.    values for the other command line options.
  137.  
  138.    LEVEL is the optimization level specified; 2 if -O2 is
  139.    specified, 1 if -O is specified, and 0 if neither is specified.  */
  140.  
  141. #define OPTIMIZATION_OPTIONS(LEVEL)                    \
  142. {                                    \
  143.   flag_gnu_linker = FALSE;                        \
  144.                                     \
  145.   if (LEVEL >= 3)                            \
  146.     flag_inline_functions = TRUE;                    \
  147. }
  148.  
  149. /* A C expression that is 1 if the RTX X is a constant which is a
  150.    valid address.  On most machines, this can be defined as
  151.    `CONSTANT_P (X)', but a few machines are more restrictive in
  152.    which constant addresses are supported.
  153.  
  154.    `CONSTANT_P' accepts integer-values expressions whose values are
  155.    not explicitly known, such as `symbol_ref', `label_ref', and
  156.    `high' expressions and `const' arithmetic expressions, in
  157.    addition to `const_int' and `const_double' expressions.  */
  158.  
  159. #undef    CONSTANT_ADDRESS_P
  160. #define CONSTANT_ADDRESS_P(X)                                           \
  161.   (CONSTANT_P (X) && (!HALF_PIC_P () || !HALF_PIC_ADDRESS_P (X)))
  162.  
  163. /* Nonzero if the constant value X is a legitimate general operand.
  164.    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.  */
  165.  
  166. #undef    LEGITIMATE_CONSTANT_P
  167. #define LEGITIMATE_CONSTANT_P(X)                    \
  168.   (!HALF_PIC_P ()                            \
  169.    || GET_CODE (X) == CONST_DOUBLE                    \
  170.    || GET_CODE (X) == CONST_INT                        \
  171.    || !HALF_PIC_ADDRESS_P (X))
  172.  
  173. /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
  174.    that is a valid memory address for an instruction.
  175.    The MODE argument is the machine mode for the MEM expression
  176.    that wants to use this address. */
  177.  
  178. #undef    GO_IF_LEGITIMATE_ADDRESS
  179. #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)                \
  180. {                                    \
  181.   if (CONSTANT_P (X))                            \
  182.     {                                    \
  183.       if (! HALF_PIC_P () || ! HALF_PIC_ADDRESS_P (X))            \
  184.     goto ADDR;                            \
  185.     }                                    \
  186.   else                                    \
  187.     {                                    \
  188.       GO_IF_INDEXING (X, ADDR);                        \
  189.                                     \
  190.       if (GET_CODE (X) == PLUS)                        \
  191.     {                                \
  192.       rtx x1 = XEXP (X, 1);                        \
  193.                                     \
  194.       if (CONSTANT_P (x1))                        \
  195.         {                                \
  196.           if (! HALF_PIC_P () || ! HALF_PIC_ADDRESS_P (x1))        \
  197.         {                            \
  198.           rtx x0 = XEXP (X, 0);                    \
  199.           GO_IF_INDEXING (x0, ADDR);                \
  200.         }                            \
  201.         }                                \
  202.     }                                \
  203.     }                                    \
  204. }
  205.  
  206. /* Sometimes certain combinations of command options do not make sense
  207.    on a particular target machine.  You can define a macro
  208.    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
  209.    defined, is executed once just after all the command options have
  210.    been parsed.  */
  211.  
  212. #define OVERRIDE_OPTIONS                        \
  213. {                                    \
  214.   if (TARGET_HALF_PIC)                            \
  215.     half_pic_init ();                            \
  216. }
  217.  
  218. /* Define this macro if references to a symbol must be treated
  219.    differently depending on something about the variable or
  220.    function named by the symbol (such as what section it is in).
  221.  
  222.    The macro definition, if any, is executed immediately after the
  223.    rtl for DECL has been created and stored in `DECL_RTL (DECL)'. 
  224.    The value of the rtl will be a `mem' whose address is a
  225.    `symbol_ref'.
  226.  
  227.    The usual thing for this macro to do is to a flag in the
  228.    `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified
  229.    name string in the `symbol_ref' (if one bit is not enough
  230.    information).
  231.  
  232.    The best way to modify the name string is by adding text to the
  233.    beginning, with suitable punctuation to prevent any ambiguity. 
  234.    Allocate the new name in `saveable_obstack'.  You will have to
  235.    modify `ASM_OUTPUT_LABELREF' to remove and decode the added text
  236.    and output the name accordingly.
  237.  
  238.    You can also check the information stored in the `symbol_ref' in
  239.    the definition of `GO_IF_LEGITIMATE_ADDRESS' or
  240.    `PRINT_OPERAND_ADDRESS'. */
  241.  
  242. #undef    ENCODE_SECTION_INFO
  243. #define ENCODE_SECTION_INFO(DECL)                    \
  244. do                                    \
  245.   {                                    \
  246.    if (HALF_PIC_P ())                                \
  247.       HALF_PIC_ENCODE (DECL);                        \
  248.   }                                    \
  249. while (0)
  250.  
  251.  
  252. /* Given a decl node or constant node, choose the section to output it in
  253.    and select that section.  */
  254.  
  255. #undef    SELECT_RTX_SECTION
  256. #define SELECT_RTX_SECTION(MODE, RTX)                    \
  257. do                                    \
  258.   {                                    \
  259.     if (MODE == Pmode && HALF_PIC_P () && HALF_PIC_ADDRESS_P (RTX))    \
  260.       data_section ();                            \
  261.     else                                \
  262.       readonly_data_section ();                        \
  263.   }                                    \
  264. while (0)
  265.  
  266. #undef    SELECT_SECTION
  267. #define SELECT_SECTION(DECL,RELOC)                    \
  268. {                                    \
  269.   if (TREE_CODE (DECL) == STRING_CST)                    \
  270.     {                                    \
  271.       if (flag_writable_strings)                    \
  272.     data_section ();                        \
  273.       else                                \
  274.     readonly_data_section ();                    \
  275.     }                                    \
  276.   else if (TREE_CODE (DECL) != VAR_DECL)                \
  277.     readonly_data_section ();                        \
  278.   else if (!TREE_READONLY (DECL))                    \
  279.     data_section ();                            \
  280.   else                                    \
  281.     readonly_data_section ();                        \
  282. }
  283.  
  284.  
  285. /* A C statement (sans semicolon) to output to the stdio stream
  286.    STREAM any text necessary for declaring the name NAME of an
  287.    initialized variable which is being defined.  This macro must
  288.    output the label definition (perhaps using `ASM_OUTPUT_LABEL'). 
  289.    The argument DECL is the `VAR_DECL' tree node representing the
  290.    variable.
  291.  
  292.    If this macro is not defined, then the variable name is defined
  293.    in the usual manner as a label (by means of `ASM_OUTPUT_LABEL').  */
  294.  
  295. #undef    ASM_DECLARE_OBJECT_NAME
  296. #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL)            \
  297. do                                    \
  298.  {                                    \
  299.    ASM_OUTPUT_LABEL(STREAM,NAME);                                       \
  300.    HALF_PIC_DECLARE (NAME);                        \
  301.  }                                    \
  302. while (0)
  303.  
  304. /* This is how to declare a function name. */
  305.  
  306. #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL)            \
  307. do                                    \
  308.  {                                    \
  309.    ASM_OUTPUT_LABEL(STREAM,NAME);                                       \
  310.    HALF_PIC_DECLARE (NAME);                        \
  311.  }                                    \
  312. while (0)
  313.  
  314. /* This says what to print at the end of the assembly file */
  315. #define ASM_FILE_END(STREAM)                        \
  316. do                                    \
  317.   {                                    \
  318.     if (HALF_PIC_P ())                            \
  319.       HALF_PIC_FINISH (STREAM);                        \
  320.   }                                    \
  321. while (0)
  322.  
  323. /* Tell collect that the object format is OSF/rose.  */
  324. #define OBJECT_FORMAT_ROSE
  325.  
  326. /* Tell collect where the appropriate binaries are.  */
  327. #define REAL_LD_FILE_NAME    "/usr/ccs/gcc/gld"
  328. #define REAL_NM_FILE_NAME    "/usr/ccs/bin/nm"
  329. #define REAL_STRIP_FILE_NAME    "/usr/ccs/bin/strip"
  330.  
  331. /* Use atexit for static constructors/destructors, instead of defining
  332.    our own exit function.  */
  333. #define HAVE_ATEXIT
  334.  
  335. /* Define this macro meaning that gcc should find the library 'libgcc.a'
  336.    by hand, rather than passing the argument '-lgcc' to tell the linker
  337.    to do the search */
  338. #define LINK_LIBGCC_SPECIAL
  339.  
  340. /* A C statement to output assembler commands which will identify the object
  341.   file as having been compile with GNU CC. We don't need or want this for
  342.   OSF1. GDB doesn't need it and kdb doesn't like it */
  343. #define ASM_IDENTIFY_GCC(FILE)
  344.  
  345. /* This is how to output an assembler line defining a `double' constant.
  346.    Use "word" pseudos to avoid printing NaNs, infinity, etc.  */
  347.  
  348. /* This is how to output an assembler line defining a `double' constant.  */
  349.  
  350. #undef    ASM_OUTPUT_DOUBLE
  351.  
  352. #ifndef    CROSS_COMPILE
  353. #define    ASM_OUTPUT_DOUBLE(STREAM, VALUE)                \
  354. do                                    \
  355.   {                                    \
  356.     long value_long[2];                            \
  357.     REAL_VALUE_TO_TARGET_DOUBLE (VALUE, value_long);            \
  358.                                     \
  359.     fprintf (STREAM, "\t.long\t0x%08lx\t\t# %.20g\n\t.long\t0x%08lx\n",    \
  360.        value_long[0], VALUE, value_long[1]);            \
  361.   }                                    \
  362. while (0)
  363.  
  364. #else
  365. #define    ASM_OUTPUT_DOUBLE(STREAM, VALUE)                \
  366.   fprintf (STREAM, "\t.double\t%.20g\n", VALUE)
  367. #endif
  368.  
  369. /* This is how to output an assembler line defining a `float' constant.  */
  370.  
  371. #undef    ASM_OUTPUT_FLOAT
  372.  
  373. #ifndef    CROSS_COMPILE
  374. #define    ASM_OUTPUT_FLOAT(STREAM, VALUE)                    \
  375. do                                    \
  376.   {                                    \
  377.     long value_long;                            \
  378.     REAL_VALUE_TO_TARGET_SINGLE (VALUE, value_long);            \
  379.                                     \
  380.     fprintf (STREAM, "\t.long\t0x%08lx\t\t# %.12g (float)\n",        \
  381.        value_long, VALUE);                        \
  382.   }                                    \
  383. while (0)
  384.  
  385. #else
  386. #define    ASM_OUTPUT_FLOAT(STREAM, VALUE)                    \
  387.   fprintf (STREAM, "\t.float\t%.12g\n", VALUE)
  388. #endif
  389.  
  390.  
  391. /* Generate calls to memcpy, etc., not bcopy, etc. */
  392. #define TARGET_MEM_FUNCTIONS
  393.  
  394.  
  395.  
  396. /* Defines to be able to build libgcc.a with GCC.  */
  397.  
  398. /* It might seem that these are not important, since gcc 2 will never
  399.    call libgcc for these functions.  But programs might be linked with
  400.    code compiled by gcc 1, and then these will be used.  */
  401.  
  402. #define perform_udivsi3(a,b)                        \
  403. {                                    \
  404.   register int dx asm("dx");                        \
  405.   register int ax asm("ax");                        \
  406.                                     \
  407.   dx = 0;                                \
  408.   ax = a;                                \
  409.   asm ("divl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (b), "d" (dx));    \
  410.   return ax;                                \
  411. }
  412.  
  413. #define perform_divsi3(a,b)                        \
  414. {                                    \
  415.   register int dx asm("dx");                        \
  416.   register int ax asm("ax");                        \
  417.                                     \
  418.   ax = a;                                \
  419.   asm ("cltd\n\tidivl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (b));    \
  420.   return ax;                                \
  421. }
  422.  
  423. #define perform_umodsi3(a,b)                        \
  424. {                                    \
  425.   register int dx asm("dx");                        \
  426.   register int ax asm("ax");                        \
  427.                                     \
  428.   dx = 0;                                \
  429.   ax = a;                                \
  430.   asm ("divl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (b), "d" (dx));    \
  431.   return dx;                                \
  432. }
  433.  
  434. #define perform_modsi3(a,b)                        \
  435. {                                    \
  436.   register int dx asm("dx");                        \
  437.   register int ax asm("ax");                        \
  438.                                     \
  439.   ax = a;                                \
  440.   asm ("cltd\n\tidivl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (b));    \
  441.   return dx;                                \
  442. }
  443.  
  444. #define perform_fixdfsi(a)                        \
  445. {                                    \
  446.   auto unsigned short ostatus;                        \
  447.   auto unsigned short nstatus;                        \
  448.   auto int ret;                                \
  449.   auto double tmp;                            \
  450.                                     \
  451.   &ostatus;            /* guarantee these land in memory */    \
  452.   &nstatus;                                \
  453.   &ret;                                    \
  454.   &tmp;                                    \
  455.                                     \
  456.   asm volatile ("fnstcw %0" : "=m" (ostatus));                \
  457.   nstatus = ostatus | 0x0c00;                        \
  458.   asm volatile ("fldcw %0" : /* no outputs */ : "m" (nstatus));        \
  459.   tmp = a;                                \
  460.   asm volatile ("fldl %0" : /* no outputs */ : "m" (tmp));        \
  461.   asm volatile ("fistpl %0" : "=m" (ret));                \
  462.   asm volatile ("fldcw %0" : /* no outputs */ : "m" (ostatus));        \
  463.                                     \
  464.   return ret;                                \
  465. }
  466.